<template>
	<div class="staComBtnDetailWrap">
        <template v-if="btnDetailType == 'hisToryWendu' && loadSuc">
			<div class="staComLi">
				<span>历史最高温度：</span><span>{{historyMaxAndMin[0].历史最高气温 || "无数据"}}℃</span>
				<span>，日期：{{historyMaxAndMin[0].历史最高气温时间 || "无数据"}}</span>
			</div>
			<div class="staComLi">
				<span>历史最低温度：</span><span>{{historyMaxAndMin[1].历史最低气温 || "无数据"}}℃</span>
				<span>，日期：{{historyMaxAndMin[1].历史最低气温时间 || "无数据"}}</span>
			</div>
		</template>
		<template v-if="btnDetailType == 'yearWind'  && loadSuc">
			<div class="staComLi">
				<span>{{yearWindArr[2].wintime || ""}}</span><span>年最大极大风速：</span><span>{{yearWindArr[2].winsinstmax || "无数据"}}</span>
			</div>
			<div class="staComLi">
				<span>{{yearWindArr[3].wintime || ""}}</span><span>年最小极大风速：</span><span>{{yearWindArr[3].winsinstmax || "无数据"}}</span>
			</div>
			<div class="staComLi">
				<span>月最大极大风速：</span><span>{{yearWindArr[0].winsinstmax || "无数据"}}</span>
				<span>，日期：{{yearWindArr[0].winsinstmax || "无数据"}}</span>
			</div>
			<div class="staComLi">
				<span>月最小极大风速：</span><span>{{yearWindArr[1].winsinstmax || "无数据"}}</span>
				<span>，日期：{{yearWindArr[1].winsinstmax || "无数据"}}</span>
			</div>
		</template>
	</div>
</template>
<script type="text/javascript">
	import meteoroStaCompreApi from '@/service/staCompre.js';
	export default{
		props:{
			btnDetailType:""
		},
		data () {
			return {
				index:0,
				historyMaxAndMin:[],
				yearWindArr:[],
				loadSuc:false,
			}
		},
		mounted (){
			this.initApi();
        },
        watch:{
            
        },
		components : {
			
		},
		methods : {
			initApi(){
				this.loadSuc = false;
				if(this.btnDetailType == "yearWendu"){
					//年最高/最低温度
					this.yearWenduApi();
				}else if(this.btnDetailType == "hisToryWendu"){
					//历史最高/最低温度
					this.hisToryWenduApi();
				}else if(this.btnDetailType == "yearShidu"){
					//年最高/最低湿度
					this.yearShiduApi();
				}else if(this.btnDetailType == "yearWind"){
					//年/月最大极大风速
					this.yearWindApi();
				}
			},
			yearWenduApi(){
				//年最高/最低温度
				var params = {
					"city":"太原市",
					"startTime":"2021-09-10 00:00:00",
					"endTime":"2021-09-10 24:00:00"
				};
				meteoroStaCompreApi.post_tb_skzdzs_jx_tempMaxAndMin(params).then(res => {

				}).catch(error => {

				})
			},
			hisToryWenduApi(){
				//历史最高/最低温度
				this.$toast.loading({
                    message: '加载中...',
                    forbidClick:true,
                    duration:0
                });
				var params = {
					histtemprovince:"山西省",
					histtemcity:"太原市"
				}
				meteoroStaCompreApi.get_tb_skzdzs_jx_histtem({}).then(res => {
					this.historyMaxAndMin = res;
					this.$toast.clear();
					this.loadSuc = true;
				}).catch(error => {
					this.$toast.clear();
				})
			},
			yearShiduApi(){
				//年最高/最低湿度
				var params = {
					"startTime":"2021-09-09 00:00:00",
					"endTime":"2021-09-09 24:00:00",
					"city":"太原市"
				}
				meteoroStaCompreApi.post_tb_skzdzs_jx_trhuYearCount(params).then(res => {

				}).catch(error => {

				})
			},
			yearWindApi(){
				//年/月最大极大风速
				this.$toast.loading({
                    message: '加载中...',
                    forbidClick:true,
                    duration:0
                });
				var params = {
					"startTime":"2022-04-14 06:00:00",
					"endTime":"2022-04-15 00:00:00",
					"city":"太原市",
					"cnty":"古交市"
				}
				meteoroStaCompreApi.post_tb_skzdzs_jx_winSinstMaxCount(params).then(res => {
					console.log(res);
					//this.yearWindArr = res.t;
					this.$toast.clear();
					this.loadSuc = false;
				}).catch(error => {
					console.log("error",error);
					this.$toast.clear();
					this.loadSuc = false;
				})
			}
		}
	}
</script>
<style type="text/css" lang="less">
	.staComBtnDetailWrap{
        padding:10px;
		.staComLi{
			font-size:16px;
			margin-bottom:10px;
		}
    }
</style>